<template>
  <div class="new-wrap">
    <div class="title">{{title}}</div>
    <div class="provenance"><span v-text="provenance"></span><span class="time" v-text="time"></span></div>
    <div class="content" v-html="essay"></div>
  </div>
</template>

<script>
  import {baseUrl} from "../../config/env"
  import {getUrlKey, formatDate} from "../../config/util"

  export default {
    data() {
      return {
        title: "",
        provenance: "",
        time: "",
        newId: getUrlKey("id"),
        essay: ""
      }
    },
    mounted() {
      this.$vux.loading.show({
        text: '加载中',
      })
      this.axios.get(baseUrl + "/essay/get_essay?id=" + this.newId).then((res) => {
        let resultObj = res.data;
        this.$vux.loading.hide();
        if (resultObj.code == 0) {
          if (resultObj.data != null) {
            this.title = resultObj.data.essayName;
            this.provenance = resultObj.data.essayAuthor;
            this.time = formatDate(new Date(resultObj.data.time), "yyyy-MM-dd hh:mm:ss");
            this.essay = resultObj.data.essayDetails;
          } else {
            this.$vux.toast.text("新闻详情内容为空", "middle");
          }
        } else {
          this.$vux.toast.text(resultObj.msg, "middle");
        }
      }).catch((error) => {
        this.$vux.loading.hide();
        this.$vux.toast.text("网络异常", "middle");
      });
    }
  }
</script>

<style lang="stylus" scoped>
  .new-wrap
    margin: 0 auto
    width: 92%
    height: auto
    .title
      margin-top: 0.2rem
      font-size: 0.5rem
      color: #1b1b1b
      line-height: 0.6rem
    .provenance
      margin-top: 0.413333rem
      font-size: 0.32rem
      color: #5e5e5e
      .time
        margin-left: 0.266666rem
    .content
      font-size: 0.4rem !important
      line-height: 0.5rem !important
      color: #333338
      >>> p
        width: 100% !important
        margin-top: 0.326666rem !important
        margin-bottom: 0rem !important
        padding: 0rem !important
        font-variant-numeric: normal !important
        font-variant-east-asian: normal !important
        font-stretch: normal !important
        font-size: 0.4rem !important
        line-height: 0.556666rem !important
        font-family: "Microsoft Yahei" !important
        color: rgb(64, 64, 64) !important
        text-align: justify !important
        white-space: normal !important
        background-color: rgb(255, 255, 255) !important
        img
          width: 100% !important
          height: 100% !important
          border-radius: 0.133333rem
          object-fit: fill
        a
          padding-left: 0.1rem !important
          padding-right: 0.1rem !important
          margin-bottom: 0.25rem !important
</style>


